package com.msmall.community.bbs.action.html;

import java.util.List;

import com.msmall.base.cache.CacheFactory;
import com.msmall.base.util.ConstantUrl;
import com.msmall.base.util.Constants;
import com.msmall.community.bbs.model.Board;
import com.msmall.community.bbs.model.Master;
import com.msmall.community.bbs.service.BoardManager;
import com.msmall.community.bbs.service.MasterManager;
import com.msmall.community.bbs.util.BbsUtil;
import com.msmall.community.common.CascadeCollection;

public class BoardAction extends BBSBaseAction{

	private static final long serialVersionUID = 7757722260250366391L;

	private Long keywordid;
	
	private List<Master> masters;
	
	private BoardManager boardManager;
	
	private MasterManager masterManager;
	
	public String execute(){
		try{
			boardCS = (CascadeCollection<Board>) CacheFactory.getInstance().getCache(Constants.CACHE_NAME_COMMON).get(Constants.CACHE_KEY_BBS_BOARD_CASCADECOLLECTION);
			if(bid == null || bid.longValue() == 0){
				bid = BbsUtil.getBBSDefaultBoard();
			}
			board = boardCS.getAllDatas().get(bid).getCurrent();
			masters = masterManager.getMastersByBoardId(bid);
			page.setPageSize(40);
			boardManager.getTopicPaginationByBoard(page, getUserid(), bid,keywordid);
			page.setUrl(ConstantUrl.HTML_BOARD_INDEX + "?bid="+bid + "&keywordid="+(keywordid==null?0:keywordid));
		}catch(Exception e){
			
		}
		return SUCCESS;
	}

	public Long getKeywordid() {
		return keywordid;
	}

	public void setKeywordid(Long keywordid) {
		this.keywordid = keywordid;
	}

	public void setBoardManager(BoardManager boardManager) {
		this.boardManager = boardManager;
	}

	public List<Master> getMasters() {
		return masters;
	}

	public void setMasters(List<Master> masters) {
		this.masters = masters;
	}

	public void setMasterManager(MasterManager masterManager) {
		this.masterManager = masterManager;
	}
}
